import { request } from "./request"

//获取角色列表
export async function getHttpRolesList() {
  return await request({
    method: "get",
    url: "roles"
  })
}

//添加角色
export async function postHttpAddRoles(info) {
  return await request({
    method: "post",
    url: "roles",
    data: info
  })
}

//根据 ID 查询角色信息
export async function getHttpGetRolesById(id) {
  return await request({
    method: "get",
    url: "roles/"+id
  })
}

//修改用户信息
export async function putHttpUpdateRolesById(info) {
  return await request({
    method: "put",
    url: `roles/${info.id}`,
    data: info
  })
}

//删除单个角色
export async function deleteHttpDeleteRolesById(id) {
  return await request({
    method: "delete",
    url: `roles/${id}`
  })
}

//删除单个权限
export async function deleteHttpDeleteRightById(roleId,rightId) {
  return await request({
    method: "delete",
    url: 'roles/'+ roleId +'/rights/' + rightId
  })
}

//获取所有权限列表
export async function getHttpRightsList(type) {
  return await request({
    method: "get",
    url: "rights/" + type
  })
}

//角色授权
export async function postHttpUpdateRolesRights(roleid,idstr) {
  return await request({
    method: "post",
    url: "roles/"+ roleid +"/rights",
    data: {
      rids: idstr
    }
  })
}